package com.ll19.service;

import java.util.List;

import javax.jws.WebService;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import com.ll19.model.User;

/**
 * Web Service interface so hierarchy of Generic Manager isn't carried through.
 */

// @javax.jws.WebService(targetNamespace = "", name = "",serviceName = "")
// targetNamespace :生成的 WSDL 中使用的名称空间
// name:Web Service 的名称，映射到 WSDL 文件中的 <wsdl:portType> 元素
// serviceName: Web Service 的服务名,映射到 WSDL 文件<wsdl:service> 元素。

@WebService
@Path("/")
@Produces({ "application/json", "application/xml" })
public interface UserService {
	/**
	 * Retrieves a user by userId. An exception is thrown if user not found
	 * 
	 * @param userId
	 *            the identifier for the user
	 * @return User
	 */
	@GET
	@Path("/user/{id}")
	User getUser(@PathParam("id") String userId);

	/**
	 * Finds a user by their username.
	 * 
	 * @param username
	 *            the user's username used to login
	 * @return User a populated user object
	 */
	@GET
	@Path("/{username}")
	User getUserByUsername(@PathParam("username") String username);

	/**
	 * Retrieves a list of all users.
	 * 
	 * @return List
	 */
	@GET
	@Path("/users")
	List<User> getUsers();

	/**
	 * Saves a user's information
	 * 
	 * @param user
	 *            the user's information
	 * @return updated user
	 * @throws UserExistsException
	 *             thrown when user already exists
	 */
	@POST
	@Path("/user")
	User saveUser(User user) throws UserExistsException;

	/**
	 * Removes a user from the database by their userId
	 * 
	 * @param userId
	 *            the user's id
	 */
	@DELETE
	@Path("/user")
	void removeUser(String userId);
}
